/*
Kiwi Editor is a framework for building WYSIWYG web editors.
Copyright (C) 2011  Roosevelt de Lima Sardinha

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Contact the author at roosevelt1@gmail.com (Roosevelt) 
*/

/* Label */
function label(){	

    this.showProperties = function(){
	   this.tabId = this.propertyBox.addTab("Label");
	   this.propertyBox.addProperty(this.tabId, 0, 0, 'label', 'Textbox', this, {
	   		label: 'Label',
			help: 'Sets the content of the label.'
	   });
   	   this.propertyBox.addProperty(this.tabId, 1, 0, 'left', 'Textbox', this, {
	   		label: 'Left',
			help: 'Sets the left coordinate of the label.'
	   });
	   this.propertyBox.addProperty(this.tabId, 2, 0, 'top', 'Textbox', this, {
	   		label: 'Top',
			help: 'Sets the top coordinate of the label.'
	   });	
	   this.propertyBox.addProperty(this.tabId, 3, 0, 'fontcolor', 'Color', this, {
	   		label: 'Font Color',
			help: 'Sets the color of the font.'
	   });	

 	   this.propertyBox.addProperty(this.tabId, 0, 2, 'font', 'Font', this, {
	   		label: 'Font',
			help: 'Sets the color of the font.'
	   });	
	   this.propertyBox.addProperty(this.tabId, 1, 2, 'fontsize', 'Textbox', this, {
	   		label: 'Font Size',
			help: 'Sets the size of the font.'
	   });
	   
    };
    
    this.setProperty = function(property, value){
        // Changes the property of  this object setting it to value.
		 switch (property) {
            case 'label':
                this.label.innerHTML = value;
                break;
            case 'fontcolor':
                this.label.style.color = value;
                break;
            case 'font':
                this.label.style.fontFamily = value;
                break;
            case 'fontsize':
                this.label.style.fontSize = value;
                break;				
            default:
                break;
        }
    };
    
    this.getProperty = function(property){
        // Gets the property of  this object
        switch (property) {
			case 'label':
				return this.label.innerHTML;
                break;
            case 'fontcolor':
                return this.label.style.color || '#000000';
                break;
            case 'fontsize':
                return this.label.style.fontSize || '12px';
                break;
            case 'font':
                return this.label.style.fontFamily || 'Arial';
                break;				
            default:
                break;
        }
    };
    
    this.JSON = function(){
        var EO_JSON = {
            label: this.getProperty('label'),
			fontcolor: this.getProperty('fontcolor'),
            fontsize: this.getProperty('fontsize'),
            font: this.getProperty('font')
		};
        return EO_JSON;
    }
	
	this.HTML = function(){
		var html = "<div style=\"top:" + this.getProperty('top') +"; left:" + this.getProperty('left') + "; position: absolute; \">"+
		"<label style=\"color:"+ this.getProperty('fontcolor') + "; font-size:"+ this.getProperty('fontsize') + "; font-family:"+ this.getProperty('font') + "; \">" + this.getProperty('label') + "</label></div>";
		
		return html;
	}
    
    this.help = "Just a simple label. It helps to add some small text to any part of the document.";
	
	this.objectList = new Array();
	this.selectorList = new Array();
	
    this.init = function(){              
		this.objectList.push('div');
		this.selectorList.push('label');
       	
		var label = document.createElement('label');
		label.innerHTML = 'Insert your text here.';
		label.style.cursor = 'move';
		this.label = label;
		
		
		var div = document.createElement('div');
		div.appendChild(label);
		
		this.div = div;	
    }
}
